package com.yanyilu.basing.wxpay;


import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.InputStream;

@ConfigurationProperties(prefix = "wxpay")
@Component
@Data
public class MyPayConfig extends WXPayConfig {
    //小程序appid
    private String app_no;
    //微信支付的商户id
    private String mch_no;
    //微信支付的商户密钥
    private String key;
    //支付成功后的服务器回调url
    private String notify_url;
    //交易类型
    private String tradeType;
    //微信统一下单接口地址
    private final String domain = WXPayConstants.DOMAIN_API;

    @Override
    public String getAppID() {
        return app_no;
    }

    @Override
    public String getMchID() {
        return mch_no;
    }

    @Override
    public String getKey() {
        return key;
    }

    public String getTradeType(){
        return tradeType;
    }



    @Override
    InputStream getCertStream(){
        //支付证书
//        InputStream input = this.getClass().getResourceAsStream("/apiclient_cert.p12");
//        //input = new FileInputStream(new File("src\\main\\resources\\apiclient_cert.p12"));
//        System.out.println(input);
//        return input;
        return null;
    }
    @Override
    IWXPayDomain getWXPayDomain() {
        return new IWXPayDomain() {
            @Override
            public void report(String domain, long elapsedTimeMillis, Exception ex) {

            }
            @Override
            public DomainInfo getDomain(WXPayConfig config) {
                return new DomainInfo(domain,true);

            }
        };
    }

    @Override
    public boolean shouldAutoReport() {
        return false;
    }
}
